/************************************************************************* > File Name: boundaryio.c
  > Author: wusihai
  > Mail: wusihai18@gmail.com 
  > Created Time: Sun 16 Feb 2020 05:50:17 PM CST
 ************************************************************************/

#include "rtmlib.h"
#include <athread.h>
#include "slavertm.h" /*
 * 六个从核pack函数io_pack
 */
/*边界打包+存储 */

extern SLAVE_FUN(SiopackX)(rtm_slave_iopack* p);
extern SLAVE_FUN(SiopackY)(rtm_slave_iopack* p);
extern SLAVE_FUN(SiopackZ)(rtm_slave_iopack* p);
extern SLAVE_FUN(SiounpackX)(rtm_slave_iopack* p);
extern SLAVE_FUN(SiounpackY)(rtm_slave_iopack* p);
extern SLAVE_FUN(SiounpackZ)(rtm_slave_iopack* p);

void boundary_packT(int it){
  int i,j,k;
  parameter_iopack.Pin[0]=Txx;
  parameter_iopack.Pin[1]=Tyy;
  parameter_iopack.Pin[2]=Tzz;
  /*1. X-方向*/
  int size=5*DivNy*DivNz;
  P1=iobufferX0T+(it%Nf)*size*3;
  P2=iobufferX0T+(it%Nf)*size*3+1*size;
  P3=iobufferX0T+(it%Nf)*size*3+2*size;


  parameter_iopack.Pout[0]=P1;
  parameter_iopack.Pout[1]=P2;
  parameter_iopack.Pout[2]=P3;

  //X方向
  if(x_rank==0){
	parameter_iopack.stX=PMLX-5;
	parameter_iopack.endX=PMLX;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=0;
	athread_spawn(SiopackX,&parameter_iopack);
	athread_join();
  }
  if(x_rank==dims[0]-1){
	parameter_iopack.stX=SubNx-PMLX-5;
	parameter_iopack.endX=SubNx-PMLX;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;
	parameter_iopack.option=1;
	athread_spawn(SiopackX,&parameter_iopack);
	athread_join();
  }

  size=DivNx*5*DivNz;
  P1=iobufferY0T+(it%Nf)*size*3;
  P2=iobufferY0T+(it%Nf)*size*3+1*size;
  P3=iobufferY0T+(it%Nf)*size*3+2*size;

  parameter_iopack.Pout[0]=P1;
  parameter_iopack.Pout[1]=P2;
  parameter_iopack.Pout[2]=P3;
  //Y方向
  if(y_rank==0){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=PMLY-5;
	parameter_iopack.endY=PMLY;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=0;
	athread_spawn(SiopackY,&parameter_iopack);
	athread_join();
  }
  if(y_rank==dims[1]-1){

	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=SubNy-PMLY-5;
	parameter_iopack.endY=SubNy-PMLY;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=1;
	athread_spawn(SiopackY,&parameter_iopack);
	athread_join();
  }

  //Z方向
  size=DivNx*DivNy*5;
  P1=iobufferZ0T+(it%Nf)*size*3;
  P2=iobufferZ0T+(it%Nf)*size*3+1*size;
  P3=iobufferZ0T+(it%Nf)*size*3+2*size;
  parameter_iopack.Pout[0]=P1;
  parameter_iopack.Pout[1]=P2;
  parameter_iopack.Pout[2]=P3;

  if(z_rank==0){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=PMLZ-5;
	parameter_iopack.endZ=PMLZ;

	parameter_iopack.option=0;
	athread_spawn(SiopackZ,&parameter_iopack);
	athread_join();

  }
  if(z_rank==dims[2]-1){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=SubNz-PMLZ-5;
	parameter_iopack.endZ=SubNz-PMLZ;

	parameter_iopack.option=1;
	athread_spawn(SiopackZ,&parameter_iopack);
	athread_join();
  }
}
void boundary_packV(int it){
  int i,j,k;
  parameter_iopack.Pin[0]=Vx;
  parameter_iopack.Pin[1]=Vy;
  parameter_iopack.Pin[2]=Vz;
  /*1. X-方向*/
  int size=5*DivNy*DivNz;
  P1=iobufferX0V+(it%Nf)*size*3;
  P2=iobufferX0V+(it%Nf)*size*3+1*size;
  P3=iobufferX0V+(it%Nf)*size*3+2*size;

  parameter_iopack.Pout[0]=P1;
  parameter_iopack.Pout[1]=P2;
  parameter_iopack.Pout[2]=P3;


  //X方向
  if(x_rank==0){
	parameter_iopack.stX=PMLX-5;
	parameter_iopack.endX=PMLX;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=0;
	athread_spawn(SiopackX,&parameter_iopack);
	athread_join();
  }
  if(x_rank==dims[0]-1){
	parameter_iopack.stX=SubNx-PMLX-5;
	parameter_iopack.endX=SubNx-PMLX;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;
	parameter_iopack.option=1;
	athread_spawn(SiopackX,&parameter_iopack);
	athread_join();
  }

  size=DivNx*5*DivNz;
  P1=iobufferY0V+(it%Nf)*size*3;
  P2=iobufferY0V+(it%Nf)*size*3+1*size;
  P3=iobufferY0V+(it%Nf)*size*3+2*size;
  parameter_iopack.Pout[0]=P1;
  parameter_iopack.Pout[1]=P2;
  parameter_iopack.Pout[2]=P3;

  //Y方向
  if(y_rank==0){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=PMLY-5;
	parameter_iopack.endY=PMLY;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=0;
	athread_spawn(SiopackY,&parameter_iopack);
	athread_join();
  }
  if(y_rank==dims[1]-1){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=SubNy-PMLY-5;
	parameter_iopack.endY=SubNy-PMLY;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=1;
	athread_spawn(SiopackY,&parameter_iopack);
	athread_join();
  }
  size=DivNx*DivNy*5;
  P1=iobufferZ0V+(it%Nf)*size*3;
  P2=iobufferZ0V+(it%Nf)*size*3+1*size;
  P3=iobufferZ0V+(it%Nf)*size*3+2*size;
  parameter_iopack.Pout[0]=P1;
  parameter_iopack.Pout[1]=P2;
  parameter_iopack.Pout[2]=P3;

  //Z方向
  if(z_rank==0){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=PMLZ-5;
	parameter_iopack.endZ=PMLZ;

	parameter_iopack.option=0;
	athread_spawn(SiopackZ,&parameter_iopack);
	athread_join();
  }
  if(z_rank==dims[2]-1){

	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=SubNz-PMLZ-5;
	parameter_iopack.endZ=SubNz-PMLZ;

	parameter_iopack.option=1;
	athread_spawn(SiopackZ,&parameter_iopack);
	athread_join();
  }
}

void boundary_writeT(int it){
  int i,j,k;
  /*1. X-方向*/
  int size=5*DivNy*DivNz;
  //X方向
  if(x_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/T.x0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferX0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(x_rank==dims[0]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/T.x1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferX0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }

  size=DivNx*5*DivNz;
  //Y方向
  if(y_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/T.y0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferY0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(y_rank==dims[1]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/T.y1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferY0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  size=DivNx*DivNy*5;
  //Z方向
  if(z_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/T.z0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferZ0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(z_rank==dims[2]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/T.z1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferZ0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
}
void boundary_writeV(int it){
  int i,j,k;
  /*1. X-方向*/
  int size=5*DivNy*DivNz;
  //X方向
  if(x_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/V.x0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferX0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(x_rank==dims[0]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/V.x1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferX0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  size=DivNx*5*DivNz;
  //Y方向
  if(y_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/V.y0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferY0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(y_rank==dims[1]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/V.y1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferY0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  size=DivNx*DivNy*5;
  //Z方向
  if(z_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/V.z0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferZ0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(z_rank==dims[2]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/V.z1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"wb");
	fwrite(iobufferZ0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
}

/*边界读取+ 解包*/
void boundary_unpackT(int it){
   int i,j,k;
  parameter_iopack.Pout[0]=Txx;
  parameter_iopack.Pout[1]=Tyy;
  parameter_iopack.Pout[2]=Tzz;
  /*1. X-方向*/
  int size=5*DivNy*DivNz;
  P1=iobufferX0T+(it%Nf)*size*3;
  P2=iobufferX0T+(it%Nf)*size*3+1*size;
  P3=iobufferX0T+(it%Nf)*size*3+2*size;


  parameter_iopack.Pin[0]=P1;
  parameter_iopack.Pin[1]=P2;
  parameter_iopack.Pin[2]=P3;

  //X方向
  if(x_rank==0){
	parameter_iopack.stX=PMLX-5;
	parameter_iopack.endX=PMLX;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=0;
	athread_spawn(SiounpackX,&parameter_iopack);
	athread_join();
  }
  if(x_rank==dims[0]-1){
	parameter_iopack.stX=SubNx-PMLX-5;
	parameter_iopack.endX=SubNx-PMLX;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;
	parameter_iopack.option=1;
	athread_spawn(SiounpackX,&parameter_iopack);
	athread_join();

  }

  size=DivNx*5*DivNz;
  P1=iobufferY0T+(it%Nf)*size*3;
  P2=iobufferY0T+(it%Nf)*size*3+1*size;
  P3=iobufferY0T+(it%Nf)*size*3+2*size;

  parameter_iopack.Pin[0]=P1;
  parameter_iopack.Pin[1]=P2;
  parameter_iopack.Pin[2]=P3;
  //Y方向
  if(y_rank==0){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=PMLY-5;
	parameter_iopack.endY=PMLY;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=0;
	athread_spawn(SiounpackY,&parameter_iopack);
	athread_join();

  }
  if(y_rank==dims[1]-1){

	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=SubNy-PMLY-5;
	parameter_iopack.endY=SubNy-PMLY;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=1;
	athread_spawn(SiounpackY,&parameter_iopack);
	athread_join();

  }

  //Z方向
  size=DivNx*DivNy*5;
  P1=iobufferZ0T+(it%Nf)*size*3;
  P2=iobufferZ0T+(it%Nf)*size*3+1*size;
  P3=iobufferZ0T+(it%Nf)*size*3+2*size;
  parameter_iopack.Pin[0]=P1;
  parameter_iopack.Pin[1]=P2;
  parameter_iopack.Pin[2]=P3;

  if(z_rank==0){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=PMLZ-5;
	parameter_iopack.endZ=PMLZ;

	parameter_iopack.option=0;
	athread_spawn(SiounpackZ,&parameter_iopack);
	athread_join();

  }
  if(z_rank==dims[2]-1){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=SubNz-PMLZ-5;
	parameter_iopack.endZ=SubNz-PMLZ;

	parameter_iopack.option=1;
	athread_spawn(SiounpackZ,&parameter_iopack);
	athread_join();

  }
}

void boundary_unpackV(int it){
 int i,j,k;
  parameter_iopack.Pout[0]=Vx;
  parameter_iopack.Pout[1]=Vy;
  parameter_iopack.Pout[2]=Vz;
  /*1. X-方向*/
  int size=5*DivNy*DivNz;
  P1=iobufferX0V+(it%Nf)*size*3;
  P2=iobufferX0V+(it%Nf)*size*3+1*size;
  P3=iobufferX0V+(it%Nf)*size*3+2*size;

  parameter_iopack.Pin[0]=P1;
  parameter_iopack.Pin[1]=P2;
  parameter_iopack.Pin[2]=P3;


  //X方向
  if(x_rank==0){
	parameter_iopack.stX=PMLX-5;
	parameter_iopack.endX=PMLX;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=0;
	athread_spawn(SiounpackX,&parameter_iopack);
	athread_join();
  }
  if(x_rank==dims[0]-1){
	parameter_iopack.stX=SubNx-PMLX-5;
	parameter_iopack.endX=SubNx-PMLX;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;
	parameter_iopack.option=1;
	athread_spawn(SiounpackX,&parameter_iopack);
	athread_join();

  }

  //Y方向
  size=DivNx*5*DivNz;
  P1=iobufferY0V+(it%Nf)*size*3;
  P2=iobufferY0V+(it%Nf)*size*3+1*size;
  P3=iobufferY0V+(it%Nf)*size*3+2*size;
  parameter_iopack.Pin[0]=P1;
  parameter_iopack.Pin[1]=P2;
  parameter_iopack.Pin[2]=P3;

  if(y_rank==0){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=PMLY-5;
	parameter_iopack.endY=PMLY;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=0;
	athread_spawn(SiounpackY,&parameter_iopack);
	athread_join();
  }
  if(y_rank==dims[1]-1){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=SubNy-PMLY-5;
	parameter_iopack.endY=SubNy-PMLY;
	parameter_iopack.stZ=0;
	parameter_iopack.endZ=DivNz;

	parameter_iopack.option=1;
	athread_spawn(SiounpackY,&parameter_iopack);
	athread_join();
  }
  size=DivNx*DivNy*5;
  P1=iobufferZ0V+(it%Nf)*size*3;
  P2=iobufferZ0V+(it%Nf)*size*3+1*size;
  P3=iobufferZ0V+(it%Nf)*size*3+2*size;
  parameter_iopack.Pin[0]=P1;
  parameter_iopack.Pin[1]=P2;
  parameter_iopack.Pin[2]=P3;

  //Z方向
  if(z_rank==0){
	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=PMLZ-5;
	parameter_iopack.endZ=PMLZ;

	parameter_iopack.option=0;
	athread_spawn(SiounpackZ,&parameter_iopack);
	athread_join();
  }
  if(z_rank==dims[2]-1){

	parameter_iopack.stX=0;
	parameter_iopack.endX=DivNx;
	parameter_iopack.stY=0;
	parameter_iopack.endY=DivNy;
	parameter_iopack.stZ=SubNz-PMLZ-5;
	parameter_iopack.endZ=SubNz-PMLZ;

	parameter_iopack.option=1;
	athread_spawn(SiounpackZ,&parameter_iopack);
	athread_join();

  }
}
void boundary_readT(int it ){
  int i,j,k;
  /*1. X-方向*/
  int size=5*DivNy*DivNz;
  //X方向
  if(x_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/T.x0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferX0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(x_rank==dims[0]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/T.x1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferX0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }

  size=DivNx*5*DivNz;
  //Y方向
  if(y_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/T.y0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferY0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(y_rank==dims[1]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/T.y1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferY0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  size=DivNx*DivNy*5;
  //Z方向
  if(z_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/T.z0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferZ0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(z_rank==dims[2]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/T.z1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferZ0T,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
}
void boundary_readV(int it){
  int i,j,k;
  /*1. X-方向*/
  int size=5*DivNy*DivNz;
  //X方向
  if(x_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/V.x0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferX0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(x_rank==dims[0]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/V.x1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferX0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  size=DivNx*5*DivNz;
  //Y方向
  if(y_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/V.y0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferY0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(y_rank==dims[1]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/V.y1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferY0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  size=DivNx*DivNy*5;
  //Z方向
  if(z_rank==0){
	char file_name[100];
	sprintf(file_name,"./boundary/V.z0.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferZ0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
  if(z_rank==dims[2]-1){
	char file_name[100];
	sprintf(file_name,"./boundary/V.z1.%d_%d.dat",my_rank,it/Nf);
	FILE*fp =fopen(file_name,"rb");
	fread(iobufferZ0V,sizeof(float),size*3*Nf,fp);
	fclose(fp);
  }
}


